package com.lvtongka.app.common

import android.os.CountDownTimer
import android.widget.TextView
import com.lvtongka.app.R
import com.lvtongka.app.common.listener.CountDownCallback

/**
 * 倒计时
 */
class VerifyCodeCountDownTimer(var timerTv: TextView,millisInFuture: Long, countDownInterval: Long, val callback: CountDownCallback) :
    CountDownTimer(millisInFuture, countDownInterval) {

    override fun onTick(millisUntilFinished: Long) {
        timerTv.isClickable = false
        var down = millisUntilFinished / 1000
        timerTv.text = "倒计时${down}S"
        timerTv.setTextColor(timerTv.resources.getColor(R.color.text81848B))
    }

    override fun onFinish() {
        //重新给Button设置文字
        timerTv.setTextColor(timerTv.resources.getColor(R.color.colorRed))
        timerTv.text = "获取验证码"
        callback.onFinish()
    }
}